package net.system.sys.service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.core.common.StrUtils;
import net.system.base.bean.SSysnotice;
import net.system.base.bean.TMessage;
import net.system.base.bean.TMessageExample;
import net.system.sys.dao.TMessageDAO;

@Service
public class MessageServiceImpl implements IMessageService {
	@Autowired
	private TMessageDAO dao;
	@Autowired
	private ICommService commService;
	@Override
	public TMessage getBean(String recId) {
		// TODO Auto-generated method stub
		return dao.selectByPrimaryKey(recId);
	}

	@Override
	public List<TMessage> getList() {
		TMessageExample example = new TMessageExample();
		TMessageExample.Criteria c = example.createCriteria();
		List<TMessage> list = dao.selectByExample(example);
		return list;
	}

	@Override
	public void insert(HashMap map) {
		TMessage record = new TMessage();
		record.setRecId( commService.getSeq("notice"));
		record.setName( StrUtils.getNotNullStrValue(map.get("name")));
		record.setContent( StrUtils.getNotNullStrValue(map.get("content")));
		dao.insert(record);
	}

	@Override
	public void update(HashMap map) {
		TMessage record = new TMessage();
		record.setRecId( StrUtils.getNotNullStrValue(map.get("recId")));
		record.setName( StrUtils.getNotNullStrValue(map.get("name")));
		record.setContent( StrUtils.getNotNullStrValue(map.get("content")));
		
		dao.updateByPrimaryKeySelective(record);

	}

}
